﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using Dropthings.Widget.Framework;
using Dropthings.Widget.Widgets;
using Dropthings.Widget.Widgets.FusionCharts;
using InfoSoftGlobal;
using System.Text;

public partial class Widgets_FusionChart_ColumWidget : System.Web.UI.UserControl, IWidget
{
    #region Fields

    private IWidgetHost _Host;

    #endregion Fields

    #region Methods

    void IEventListener.AcceptEvent(object sender, EventArgs e)
    {
        throw new NotImplementedException();
    }

    void IWidget.Closed()
    {
    }

    void IWidget.Collasped()
    {
    }

    void IWidget.Expanded()
    {
    }

    void IWidget.HideSettings(bool userClicked)
    {
        SettingsPanel.Visible = false;
    }

    void IWidget.Init(IWidgetHost host)
    {
        this._Host = host;
    }

    void IWidget.Maximized()
    {
    }

    void IWidget.Restored()
    {
    }

    void IWidget.ShowSettings(bool userClicked)
    {
        SettingsPanel.Visible = true;
    }
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
        
    }

    string strXML;
    protected void Page_Load(object sender, EventArgs e)
    {

            if (!ScriptManager.GetCurrent(Page).IsInAsyncPostBack || ViewState["HasAlreadyLoaded"] == null)
            {
                
            }

            Literal1.Text = "";
            //Create an XML data document in a string variable
            string link = "javascript:updateChart('A');";
            StringBuilder strXML = new StringBuilder();
            strXML.AppendFormat("<chart caption='Monthly Sales Summary' subcaption='For the year 2008' ");
            strXML.AppendFormat(" xAxisName='Month' yAxisName='Sales' numberPrefix='$' showNames='1' ");
            strXML.AppendFormat(" showValues='0' showColumnShadow='1' animation='1' ");
            strXML.AppendFormat(" baseFontColor='666666' lineColor='FF5904' lineAlpha='85' ");
            strXML.AppendFormat(" valuePadding='10' labelDisplay='rotate' useRoundEdges='1' >");
            strXML.AppendFormat(" <set label='januári' link='{0}' value='17400'  /> ", link);
            strXML.AppendFormat(" <set label='Fevruários' value='19800' /> ");
            strXML.AppendFormat(" <set label='أبريل' value='23800' /> ");
            strXML.AppendFormat(" <set label='五月' value='29600' /> ");
            strXML.AppendFormat(" <styles><definition><style name='myCaptionFont' type='font' size='12'/></definition> ");
            strXML.AppendFormat(" <application><apply toObject='datalabels' styles='myCaptionFont' /></application></styles> ");
            strXML.AppendFormat(" </chart> ");

            Literal1.Text = FusionCharts.RenderChartHTML("../FusionCharts/Column2D.swf", "", strXML.ToString(), "myFirst", "370", "247", false, false);
        
            String sEventArguments = Request["__EVENTARGUMENT"];
            if (sEventArguments != null)
            {
                //extract arguments passed to the HTTP Request  
                Int32 iDelimiter = sEventArguments.IndexOf('$');
                String sArgument = sEventArguments.Substring(iDelimiter + 1);
                // extract the name of the post back function 
                if (sEventArguments.StartsWith("drillDown"))
                {
                    // call the post back function passing the argument(s)
                    string s=sArgument;
                }
            }
        
        
    }
    #endregion Methods
}